package com.flink.api.unit3;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;
import java.util.List;

/**
 * source_1
 *
 * @author caizhiyang
 * @since 2024-02-21
 */
public class source_1 {

    /**
     * 从集合中读取数据
     * @param args
     */
    public static void main(String[] args) throws Exception {
        //1.获取执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //2.构造数据
        List<Integer> data = Arrays.asList(1, 2, 3, 4);

        //3.读取集合数据
        DataStreamSource<Integer> streamSource = env.fromCollection(data);

        //4.打印流
        streamSource.print();

        //5.程序执行
        env.execute();
    }
}
